package com.elsa.smart_buffet.controller;

import com.elsa.smart_buffet.pojo.ResultBox.ResponseResult;
import com.elsa.smart_buffet.service.OrderService;
import com.elsa.smart_buffet.service.OrderTempService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @ClassName : AndroidController  //类名
 * @Author : elsa //作者
 */
@RestController
@CrossOrigin
@Slf4j
public class AndroidController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private OrderTempService orderTempService;

    @RequestMapping("/Android/hello")
    public String hello() {
        return "Hello, welcome to the smart self-service catering system, please put the dishes under the camera to identify and order";
    }

    @PostMapping("/Android/order/list")
    public ResponseResult insertOrderTemp(@RequestBody List<Map<String, Object>> list) throws InterruptedException {
        log.info(String.valueOf(list));
        return orderTempService.insertOrderTemp(list);
    }

    @GetMapping("/Android/order/selectList")
    public ResponseResult selectOrderTemp() throws InterruptedException {
//        log.info(String.valueOf(list));
//        return orderTempService.insertOrderTemp(list);
        return orderTempService.selectOrderTemp();
    }

    @GetMapping("/Android/order/deleteList")
    public ResponseResult deleteOrderTemp() throws InterruptedException {
//        log.info(String.valueOf(list));
//        return orderTempService.insertOrderTemp(list);
        return orderTempService.deleteOrderTemp();
    }

}
